package cate.game.role.farm.guildFairyland.msg;

import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgOutput;
import cate.game.client.msg.id.MsgIdGuild;
import cate.game.role.Role;
import cate.game.role.farm.PlayTimes;
import cate.game.role.res.guild.po.fairyland.GuildFairylandPO;
import easy.java.dev.note.NoteField;
import lombok.NoArgsConstructor;

import java.util.Optional;

@NoArgsConstructor
@ClientMsg(title = "公会秘境信息 返回")
public class GuildFairyInfoResp implements MsgOutput {
    @NoteField("挑战次数")
    public PlayTimes playTimes;
    @NoteField("主要信息")
    public GuildFairylandPO mainInfo;

    @Override
    public MsgConfig conf() {
        return MsgIdGuild.GUILD_FAIRY_INFO_RESP;
    }

    public GuildFairyInfoResp(Role role) {
        playTimes = role.getFarm().guildFairyland.playTimes;
        mainInfo = Optional.ofNullable(role.getRes().guild.getGuild())
                .map(guild -> guild.fairyland)
                .orElse(null);
    }
}
